﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;

using Kwan.Data;
using BG.Data;

namespace BG.Service
{
    public class RoomQuery
    {

        public static Expression MakeSearchWhere(NameValueCollection ps)
        {
            Expression exp = new Expression();

            string propName = "EntityID";
            if (!string.IsNullOrEmpty(ps[propName]))
                exp &= TRoom.entityID == int.Parse(ps[propName]);

            propName = "cid";
            if (!string.IsNullOrEmpty(ps[propName]))
            {
                exp &= TRoom.cid == int.Parse(ps[propName]);
            }
            propName = "floor";
            if (!string.IsNullOrEmpty(ps[propName]))
            {
                exp &= TRoom.floor == ps[propName];
            }
            propName = "roomNO";
            if (!string.IsNullOrEmpty(ps[propName]))
            {
                exp &= TRoom.roomNO.Like("%" + ps[propName] + "%");
            }

            return exp;
        }
    }
}